# -*- coding: utf-8 -*-

"""
替换对话框模块，实现显示替换对话换。
"""

from PyQt4.QtGui import QDialog
from PyQt4.QtCore import pyqtSignature

from Ui_ReplaceDialog import Ui_Dialog

class ReplaceDialog(QDialog, Ui_Dialog):
    """
    替换对话框类
    """
    def __init__(self, parent = None):
        """
        加载Ui，初始化数据
        """
        QDialog.__init__(self, parent)
        
        self.ok = False
        self.replaceAll = False
        self.ori = ""
        self.new = ""
        self.setupUi(self)
    
    @pyqtSignature("")
    def on_buttonBox_accepted(self):
        """
        点解accept处理函数，更新ok状态true，更新ori、new的数据。
        """
        self.ok = True
        self.ori = self.txt_find.text()
        self.new = self.txt_replace.text()
    
    @pyqtSignature("")
    def on_buttonBox_rejected(self):
        """
        点击reject处理函数，更新ok状态为false。
        """
        self.ok = False
